Elisp: Positions

Table of Contents

A position is the index between 2 characters or before the 1st character in the text of a buffer. It starts from 1 (which is before the 1st characer). Positions can also be represented by markers, special objects that relocate automatically when text is inserted or deleted.

1. Point

Commands move point through texts to allow editing and insertion at different places.

Each buffer has its own value point, which is independent of points in other buffers.

Each window also have a value of point, which is independent of the value of points in other windows on the same buffer.

point
Returns the value of point in the current buffer
point-min
Returns the minimum accessible value of point in the current buffer.
point-max
Returns the maximum accessible value of point.
buffer-end FLAG
Returns point-max if flag is greater than 0, point-min otherwise.
buffer-size &optional BUFFER
Returns total number of characters of the buffer (current buffer by default).

2. Motion

Motion functions change the value of point.

2.1. Motion by Characters

goto-char POSITION

Sets point in the current buffer to POSITION. If narrowing, POSITION still counts from the beginning of buffer, but the point cannot go outside the accessible portion and will go to the beginning or end of accessible portion.

When this function is called interactively, POSITION is the numeric prefix argument if provided; otherwise it’s read from minibuffer.

This function returns POSITION.

forward-char &optional COUNT

This function moves point COUNT positions forward (towards the end of buffer; or backward, if COUNT is negative). If COUNT is nil, it’s 1 by default.

Attempting to move past the beginning or end will raise an error symbol: beginning-of-buffer or end-of-buffer.

In an interactive call, COUNT is the numeric prefix argument.

backward-char &optional COUNT
Almost same as forward-char, but opposite direction.

2.2. Motion by Words

forward-word &optional COUNT
backward-word &optional COUNT
words-include-escapes
inhibit-field-text-motion
find-word-boundary-function-table
forward-word-strictly &optional COUNT
backward-word-strictly &optional COUNT

2.3. Motion to an End of the Buffer

2.4. Motion by Text Lines

2.5. Motion by Screen Lines

2.6. Motion over Balanced Expressions

2.7. Skipping Characters

Date: 2026-07-23 Thu